from django import forms
from web import models
from web.forms.bootstrap import BootStrapForm

class WikiModelFrom(BootStrapForm,forms.ModelForm):
    class Meta:
        model = models.Wiki
        exclude=['project','depth']

    def __init__(self,request,*args,**kwargs):
        super().__init__(*args,**kwargs)

        #找到想要的字段把他绑定的信息进行重置
        #数据 = 去数据库中获取当前项目 所有的wiki
        total_data = [("","请选择")]
        data_list = models.Wiki.objects.filter(project=request.tracer.project).values_list('id','title')
        total_data.extend(data_list)
        self.fields['parent'].choices = total_data
